<template>
	<view>
		<view style="background-color: #fff;padding:20rpx;">
			<view style="display: flex;justify-content: center;margin-top: 20rpx;">
				<view style="width: 100%; margin: 0 20rpx;">
					<u-search placeholder="搜索用户姓名或者电话" height="60" searchIconSize="38" v-model="search" :show-action="false" @search="searchFn"></u-search>
				</view>
			</view>
		</view>
		<mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption"
			:up="upOption">
			<view style="margin-top: 20rpx;">
				<view v-for="(item,index) in list" style="background-color: #fff; margin-bottom: 20rpx;padding: 20rpx;"
					:key="index" @click="openPage('pages/team/teamInfo', {id: item.id})">
					<view
						style="display: flex;flex-direction: row;justify-content: space-between; align-items: center;padding-bottom: 20rpx;">
						<view style="display: flex;justify-content: center;align-items: center;flex-direction: row;">
							<u-avatar :src="item.avatar" size="90"></u-avatar>
							<view
								style="display: flex;justify-content: space-between;flex-direction: column;margin-left: 20rpx;">
								<text style="margin-bottom: 20rpx;margin-left: 10rpx;">{{item.nick_name}}</text>
								<view
									:style="{background: `url(${images.levelBg})`,backgroundRepeat: 'no-repeat', backgroundSize: 'cover', width: '98rpx', height: '32rpx', fontSize: '18rpx', color: '#6C2A09', display: 'flex', alignItems: 'center', justifyContent: 'center',lineHeight: '32rpx'}">
									{{item.level_text}}
								</view>
							</view>
						</view>
						<view style="display: flex;flex-direction: column;align-items: flex-end;">
							<text style="font-size: 24rpx;color: #999;margin-bottom: 8rpx;">{{item.create_time}}</text>
							<view v-if="item.real_name_status == 0" style="font-size: 26rpx;color: #999;">未实名</view>
							<view v-if="item.real_name_status == 1" style="font-size: 26rpx;color: #999;">已实名</view>
							<view style="color:#378EFB;margin-top:10rpx;">查看详情</view>
						</view>
					</view>
					
				</view>
			</view>
		</mescroll-body>
	</view>
</template>

<script>
	import imagesUrl from '../../common/images.js'
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	import gewuSubsection from "../../components/gewu-subsection.vue";
	import { myTeam } from '@/common/team.api.js';
	export default {
		components: {
			gewuSubsection
		},
		mixins: [MescrollMixin],
		data() {
			return {
				list: [],
				search: null,
				params: [],
				searchUserId: null,
				today_order_num: 0,
				total_order_num: 0,
				total_team_num: 0,
				direct_num: 0,
				direct_partner_num: 0,
				indirect_num: 0,
				member_num: 0,
				pagination: {
					current: 1,
					pageSize: 0,
					total: 0,
				},
				upOption: {
					page: {
						size: 20 // 每页数据的数量,默认10
					},
					empty: {
						tip: '暂无相关数据'
					},
					textNoMore: "没有更多数据了"
				},
				subsection: [{
						name: '按时间排序'
					},
					{
						name: '按订单排序'
					}
				],
				curNow: 0,
				radio: [{
						name: '只看合伙人',
						value: 0,
						checked: false
					},
					{
						name: '只看有效会员',
						value: 1,
						checked: false
					}
				],
				radioValue: 1,
				images: {},
				sort: 'time',
				partner: 0,
				member: 0
			}
		},
		onLoad(params) {
			this.params = params
			this.images = imagesUrl.my
		},
		methods: {
			openPage(path, params) {
				this.$u.route({
					url: path,
					params
				})
			},
			// sectionChange(index) {
			// 	console.log(index)
			// 	this.curNow = index;
			// 	if (index == 0) {
			// 		this.sort = 'time'
			// 	} else if (index == 1) {
			// 		this.sort = 'order'
			// 	}
			// 	this.pagination.current = 1
			// 	this.getData()
			// },
			// checkboxChange(e) {
			// 	console.log(e)
			// 	for (let i = 0; i < this.radio.length; i++) {
			// 		this.radio[i].checked = false
			// 		if (this.radio[i].name == e.name) {
			// 			this.radio[i].checked = e.value
			// 		}
			// 	}
			// 	if (e.name == "只看合伙人" && e.value == true) {
			// 		this.partner = 1
			// 		this.member = 0
			// 	} else if (e.name == "只看有效会员" && e.value == true) {
			// 		this.partner = 0
			// 		this.member = 1
			// 	} else {
			// 		this.partner = 0
			// 		this.member = 0
			// 	}
			// 	this.pagination.current = 1
			// 	this.getData()
			// },
			// checkboxGroupChange(e) {
			// 	console.log(e)
			// },
			searchFn(value){
				this.pagination.current = 1
				this.search = value
				this.getData()
			},
			getData() {
				let that = this;
				let params= {
					page: that.pagination.current,
					pageSize: 20,
				};
				if(this.search){
					params.search = this.search
				}
				if(this.searchUserId){
					params.user_id = this.searchUserId
				}
				myTeam({...params, ...this.params}).then(res => {
					that.mescroll.endByPage(res.user.length, res.pagination.total)
					if (that.pagination.current == 1) {
						that.list = res.user
					} else {
						that.list = [...that.list, ...res.user]
					}
					that.pagination.current++
				})
			},
			upCallback() {
				this.getData()
			},
			downCallback() {
				this.pagination.current = 1;
				this.mescroll.resetUpScroll();
			},
			copy(text) {
				let that = this;
				uni.setClipboardData({
					data: text,
					success: function() {
						console.log(1111)

					}
				});
			}
		}
	}
</script>

<style>
	body {
		background-color: #f5f5f5;
	}

	
</style>
